function handleData(params) {
    if (params?.optionsConfig?.isNewData) {
        let createdNodes = [], createdEdges = []
        let {data: {nodes, edges}, configuration, optionsConfig} = params
        for (let i = 0; i < nodes.length; i++) {
            let newNode = {style: {}, data: {}, states: []}
            if (configuration.nodeId) {
                newNode.id = (nodes[i][configuration.nodeId]).toString()
            }
            if (configuration.nodeLabel) {
                newNode.style.labelText = nodes[i][configuration.nodeLabel]
            }
            if (configuration.nodeType) {
                newNode.data.nodeType = nodes[i][configuration.nodeType]
            }
            if (nodes[i].style) {
                newNode.style = {...newNode.style, ...nodes[i].style}
            }
            newNode.style.originalProperties = {...nodes[i]}
            createdNodes.push(newNode)
        }
        for (let i = 0; i < edges.length; i++) {
            let newEdge = {style: {}, data: {}}
            if (configuration.target) {
                newEdge.target = (edges[i][configuration.target]).toString()
            }
            if (configuration.source) {
                newEdge.source = (edges[i][configuration.source]).toString()
            }
            if (configuration.edgeId) {
                newEdge.id = edges[i][configuration.edgeId]
            }
            if (configuration.edgeLabel) {
                newEdge.style.labelText = edges[i][configuration.edgeLabel]
            }
            newEdge.style.originalProperties = {...edges[i]}
            createdEdges.push(newEdge)
        }
        return {

            data: {
                nodes: createdNodes,
                edges: createdEdges
            },
            optionsConfig,
            configuration
        }
    } else {
        return params
    }
}

export {handleData}
